
Partial Class UEdit
    Inherits System.Web.UI.Page
    Dim str As String

    Protected Sub UEdit_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("type") <> "user" Then
            Response.Redirect("Error.aspx")
            Exit Sub
        End If

        lnkProfName.Text = "Logged in as " & Session("prim") & " (" & Session("sec") & ")"
        str = Session("uid")

        If Me.IsPostBack = False Then

            'code for disable the cache
            '|||||||||||||||||||||||||||||||||||||||||||||||||||||||
            Response.Cache.SetCacheability(HttpCacheability.NoCache)
            '|||||||||||||||||||||||||||||||||||||||||||||||||||||||


            Dim b As New Globo
            b.executesql("select * from Countries", False)
            While b.dr.Read = True
                ddlCon.Items.Add(b.dr(0))
            End While
            b.dr.Close()



            Dim a As New Globo
            a.executesql("select uemail, fname, mname, lname, gender, country, loc, zip, uemail_sec, sec_quest, s_ans from users where uid = '" & str & "'", False)

            If a.dr.Read = True Then
                txtUEmail.Text = a.dr(0)
                txtFname.Text = a.dr(1)
                txtMname.Text = a.dr(2)
                txtLname.Text = a.dr(3)
                ddlGen.Text = a.dr(4)
                ddlCon.Text = a.dr(5)
                txtLoc.Text = a.dr(6)
                txtZip.Text = a.dr(7)
                txtSecEmail.Text = a.dr(8)
                txtSecQuest.Text = a.dr(9)
                txtAns.Text = a.dr(10)
                a.dr.Close()
            End If
        End If
    End Sub

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        'Blank Filed Validation Check
        '++++++++++++++++++++++++++++++++++++++++++
        If txtUEmail.Text = "" Then
            lblErr.Text = "Enter Email ID"
            lblErr.Visible = True
            Exit Sub
        End If

        If txtFname.Text = "" Then
            lblErr.Text = "Enter First Name"
            lblErr.Visible = True
            Exit Sub
        Else
            str = txtFname.Text
            str = UCase(Left(str, 1)) & LCase(Right(str, str.Length - 1))
            txtFname.Text = str
        End If

        If txtLname.Text = "" Then
            lblErr.Text = "Enter Last Name"
            lblErr.Visible = True
            Exit Sub
        Else
            str = txtLname.Text
            str = UCase(Left(str, 1)) & LCase(Right(str, str.Length - 1))
            txtLname.Text = str
        End If

        If ddlGen.Text = "" Then
            lblErr.Text = "Select Gender"
            lblErr.Visible = True
            Exit Sub
        End If

        If ddlCon.Text = "" Then
            lblErr.Text = "Select Country"
            lblErr.Visible = True
            Exit Sub
        End If

        If txtLoc.Text = "" Then
            lblErr.Text = "Enter Your Location"
            lblErr.Visible = True
            Exit Sub
        End If

        If txtZip.Text = "" Then
            lblErr.Text = "Enter Pin/Zip Code"
            lblErr.Visible = True
            Exit Sub
        End If

        If txtSecQuest.Text = "" Then
            lblErr.Text = "Enter Security Question"
            lblErr.Visible = True
            Exit Sub
        End If

        If txtAns.Text = "" Then
            lblErr.Text = "Enter Answer to Security Question"
            lblErr.Visible = True
            Exit Sub
        End If

        '++++++++++++++++++++++++++++++++++++++++++

        'Numeric validation
        '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        If IsNumeric(txtFname.Text) Then
            lblErr.Text = "Invalid First Name"
            lblErr.Visible = True
            Exit Sub
        End If

        If txtMname.Text <> "" And IsNumeric(txtMname.Text) Then
            lblErr.Text = "Invalid Middle Name"
            lblErr.Visible = True
            Exit Sub
        End If

        If IsNumeric(txtLname.Text) Then
            lblErr.Text = "Invalid Last Name"
            lblErr.Visible = True
            Exit Sub
        End If
        '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

        Dim a As New Globo
        a.executesql("update users set uemail='" & txtUEmail.Text & "', fname='" & txtFname.Text & "', mname='" & txtMname.Text & "', lname='" & txtLname.Text & "', gender='" & ddlGen.Text & "', country='" & ddlCon.Text & "', loc='" & txtLoc.Text & "', zip='" & txtZip.Text & "', uemail_sec='" & txtSecEmail.Text & "', sec_quest='" & txtSecQuest.Text & "', s_ans='" & txtAns.Text & "' where uid = '" & str & "'", True)

        Session("uemail") = txtUEmail.Text
        Response.Redirect("UProfile.aspx")

    End Sub

    Protected Sub lnkChngPass_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkChngPass.Click
        Response.Redirect("PasswordChange.aspx")
    End Sub

    '_________________________________________________________________________________________________________________________________
    '#################################################################################################################################
    Protected Sub lnkProfName_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkProfName.Click
        Response.Redirect("UProfile.aspx")
    End Sub

    'Protected Sub lnkQuery_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkQuery.Click
    '    Response.Redirect("Query.aspx")
    'End Sub

    Protected Sub lnkThemes_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkThemes.Click
        Response.Redirect("Themes.aspx")
    End Sub

    Protected Sub lnkSettings_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkSettings.Click
        Response.Redirect("Settings.aspx")
    End Sub

    Protected Sub lnkLogOut_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkLogOut.Click
        Server.Transfer("Loading.aspx")
    End Sub

    '_____________________________________________________________________________________________________________
    '*************************************************************************************************************
    Protected Sub lnkAboutUs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkAboutUs.Click
        Response.Redirect("AboutUs.aspx")
    End Sub

    Protected Sub lnkTermCond_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkTermCond.Click
        Response.Redirect("TermsConditions.aspx")
    End Sub

    Protected Sub lnkContactUs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkContactUs.Click
        Response.Redirect("ContactUs.aspx")
    End Sub

    Protected Sub lnkFAQs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFAQs.Click
        Response.Redirect("FAQs.aspx")
    End Sub

    Protected Sub lnkFeedback_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkFeedback.Click
        Response.Redirect("Feedback.aspx")
    End Sub
End Class